<template>
	<view class="recommend-pro-list">
		<view class="recommend-pro-big-item" v-if="first">
			<image :lazy-load="true" :src="first.image" mode="aspectFill" @click="Recommend"></image>
		</view>
		<view v-if="type==23 && list.length">
			<view class="tabs">
				<u-tabs 
					:current="tabIndex"
					:list="list" 
					name="name" 
					:show-bar="false" 
					height="52" 
					font-size="24"
					:bold="false"
					inactive-color="#757575"
					active-color="#FFF"
					:active-item-style="{
						backgroundColor: '#141414',
						borderRadius: '10rpx',
						marginLeft: '20rpx',
					}"
					:item-style="{
						marginLeft: '20rpx',
						backgroundColor: '#F2F0F0',
						borderRadius: '10rpx'
					}"
					@change="changeTab">
				</u-tabs>
			</view>
			<scroll-view class="recomment-pro-scroll-view" scroll-x v-for="(data,index) in list" :key="index" v-if="tabIndex==index">
				<block v-if="data.shelf_tab.length">
					<view class="recommend-pro-small-item" v-for="(item,i) in data.shelf_tab" :key="i" @click="goProDetaild(item.goods_id)">
						<image :lazy-load="true" :src="item.image" mode="aspectFill"></image>
						<view class="recommend-pro-small-item-tit">{{item.goods_name}}</view>
						<view class="recommend-pro-small-item-price" v-if="isLogin">￥<text>{{item.retail_price}}</text></view>
						<view class="noLogin" v-else>登录查看会员价</view>
					</view>
				</block>
				<pt-nothing text="暂无数据" bgColor="#FFFFFF" v-else></pt-nothing>
			</scroll-view>
		</view>
		<scroll-view class="recomment-pro-scroll-view" v-if="list.length && type!=23" scroll-x>
			<view class="recommend-pro-small-item" v-for="(data,index) in list" :key="index"  @click="goProDetaild(data.goods_id)">
				<image :lazy-load="true" :src="data.image" mode="aspectFill"></image>
				<view class="recommend-pro-small-item-tit">{{data.goods_name}}</view>
				<view class="recommend-pro-small-item-price" v-if="isLogin">￥<text>{{data.retail_price}}</text></view>
				<view class="noLogin" v-else>登录查看会员价</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: Number,
				default: 0
			},
			isLogin: {
				type: Boolean,
				default: false
			},
			first: {
				type: Object,
				default () {
					return {}
				}
			},
			list: {
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				tabIndex: 0
			};
		},
		mounted() {
			// console.log(this.list)
		},
		methods: {
			goProDetaild(goods_id){
				getApp().goProInfo(goods_id)
				this.$emit('GoInfoAddFoot')
			},
			Recommend(){
				this.$emit('Recommend')
			},
			changeTab(e){
				this.tabIndex = e
			}
		}
	}
</script>

<style lang="scss">
	.recommend-pro-list{
		box-shadow: 0rpx 20rpx 40rpx 0 rgba(40,34,31,0.05);
		border-radius: 16rpx;
		.tabs{
			padding: 30rpx 30rpx 0 10rpx;
		}
		.recommend-pro-big-item{
			position: relative;
			image{
				width: 100%;
				border-radius: 16rpx 16rpx 0 0;
				height: 552rpx;
			}
			.recommend-pro-big-item-tit{
				position: absolute;
				bottom: 0;
				left: 0;
				right: 0;
				padding: 30rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				color: #FFF;
				font-size: 36rpx;
				font-weight: bold;
				background: linear-gradient(0deg,#28221F,rgba(255,255,255,0));
			}
		}
	}
	.recomment-pro-scroll-view{
		white-space: nowrap;
		padding: 30rpx;
		box-sizing: border-box;
		.recommend-pro-small-item{
			display: inline-block;
			width: calc((100% - 40rpx) / 3);
			margin-right: 20rpx;
			&:last-child{
				margin-right: 0;
			}
			.recommend-pro-small-item-tit{
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				margin: 25rpx 0;
				font-size: 24rpx;
			}
			.recommend-pro-small-item-price{
				font-size: 20rpx;
				color: #F59359;
				font-family: 'din';
				text{
					font-size: 28rpx;
				}
			}
			.noLogin{
				display: inline-block;
				background-color: #F59359;
				color: #FFF;
				border-radius: 10rpx;
				padding: 6rpx 12rpx;
				font-size: 20rpx;
			}
			image{
				width: 196rpx;
				height: 196rpx;
				border-radius: 8rpx;
			}
		}
	}
</style>